export default function generateNode(graph, nodeData) {
  let [nodeClass, nodeType] = (nodeData.type || "flow.process").split(".");
  let width = 160;
  let height = 80;
  if (nodeClass === "flow" && nodeType === "termination") {
    height = 70;
  }
  if (nodeClass === "flow" && nodeType === "decision") {
    width = 200;
  }
  let resNode = graph.createNode({
    shape: "vue-shape",
    width: width,
    height: height,
    data: nodeData,
    ports: {
      groups: {
        top: {
          position: "top",
          label: {
            position: "top",
          },
          attrs: {
            circle: {
              r: 4,
              magnet: true,
              strokeWidth: 1,
            },
            text: {
              fontSize: 10,
              fontWeight: 400,
            },
          },
        },
        right: {
          position: "right",
          label: {
            position: "right",
          },
          attrs: {
            circle: {
              r: 4,
              magnet: true,
              strokeWidth: 1,
            },
            text: {
              fontSize: 10,
              fontWeight: 400,
            },
          },
        },
        bottom: {
          position: "bottom",
          label: {
            position: "bottom",
          },
          attrs: {
            circle: {
              r: 4,
              magnet: true,
              strokeWidth: 1,
            },
            text: {
              fontSize: 10,
              fontWeight: 400,
            },
          },
        },
        left: {
          position: "left",
          label: {
            position: "left",
          },
          attrs: {
            circle: {
              r: 4,
              magnet: true,
              strokeWidth: 1,
            },
            text: {
              fontSize: 10,
              fontWeight: 400,
            },
          },
        },
      },
      items: [
        { id: "port1", group: "top" },
        { id: "port2", group: "right" },
        { id: "port3", group: "bottom" },
        { id: "port4", group: "left" },
      ],
    },
    component: "vue-flow-node",
  });
  return resNode;
}
